import {request} from '@/utils/request'

const apiUrl = '/api/v1/'

// 获取网关
export function getSensorGw(id) {
    return request({
        url: `${apiUrl}bind/getSensorGw/${id}`,
        method: 'get'
    })
}

// 获取配置
export function configDecodeId(id) {
    return request({
        url: `${apiUrl}config/decode/${id}`,
        method: 'post',
    })
}

// 保存
export function configSaveFile(data) {
    return request({
        url: `${apiUrl}config/saveFile`,
        method: 'post',
        data,
    })
}

// 发送RTU
export function sendRtuConfig(data) {
    return request({
        url: `${apiUrl}config/sendRtuConfig`,
        method: 'post',
        data,
    })
}

// 发送RTU[单个]
export function sendConfigFile(data) {
    return request({
        url: `${apiUrl}config/sendConfigFile`,
        method: 'post',
        data,
    })
}

// 基础发送
export function sendConfig(data) {
    return request({
        url: `${apiUrl}config/sendConfig`,
        method: 'post',
        data,
    })
}

export function getConfigStatus(id) {
    return request({
        url: `${apiUrl}config/getConfigStatus/${id}`,
        method: 'get'
    })
}

// 保存RTU
export function saveRtuFile(data) {
    return request({
        url: `${apiUrl}config/saveRtuFile`,
        method: 'post',
        data,
    })
}

// 同步RTU
export function saveRtuCopy(data) {
    return request({
        url: `${apiUrl}config/copy`,
        method: 'post',
        data,
    })
}

// 获取RTU对应选择
export function getSensorByGw(id) {
    return request({
        url: `${apiUrl}bind/getSensorByGw/${id}`,
        method: 'get'
    })
}

// RTU生成
export function genRtuConfig(data) {
    return request({
        url: `${apiUrl}config/genRtuConfig`,
        method: 'post',
        data,
    })
}